package name.weily.liba.tools

class Counter constructor(number: Int = 0) {

    @Volatile private var count = number

    @Synchronized
    fun increase(cnt: Int = 1) {
            count += cnt
    }

    @Synchronized
    fun decrease(extra: Int = 1) {
            count -= extra
    }

    @Synchronized
    fun reset(init: Int = 0) {
            count = init
    }

    @Synchronized
    fun getCount() : Int {
            return count
    }
}